/* infoScoop OpenSource
 * Copyright (C) 2012 Beacon IT Inc.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-3.0-standalone.html>.
 */

package org.infoscoop.context;

import java.text.SimpleDateFormat;
import java.util.TimeZone;

public class UserInfo {
	private int clientTimezoneOffset;
	private TimeZone clientTimezone = TimeZone.getTimeZone("UTC");

	public int getClientTimezoneOffset(){
		return this.clientTimezoneOffset;
	}
	
	public void setClientTimezoneOffset(int offset){
		this.clientTimezoneOffset = offset;

		TimeZone tz = TimeZone.getTimeZone("UTC");
		tz.setRawOffset(offset * 60000);
		setClientTimezone(tz);
	}
	
	public TimeZone getClientTimezone(){
		return this.clientTimezone;
	}

	public void setClientTimezone(TimeZone tz){
		this.clientTimezone = tz;
	}
	
	public SimpleDateFormat getClientDateFormat(String format){
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		sdf.setTimeZone(getClientTimezone());
		return sdf;
	}	
}
